/**clock_t times */
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#include<sys/times.h>
#include<unistd.h>

int main(void)
{
	clock_t t_start, t_end;
	struct tms t_buf_start, t_buf_end;
	long tck;
	int i,j;
	tck=sysconf(_SC_CLK_TCK);
	t_start=times(&t_buf_start);
	if(-1==t_start){
		perror("start times error");
		exit(-1);
	}
	/******have a test********/
	for(i=0;i<20000;i++){
		for(j=0;j<20000;j++);
	}
	sleep(1)
	t_end=times(&t_buf_end);
	if(-1==t_end){
		perror("end times error");
		exit(-1);
	}
	printf("total time:%f sec\n",(t_end-t_start)/(double)tck);
	printf("usr time:%f sec\n",(t_buf_end.tms_utime-t_buf_start.tms_utime)/(double)tck);
	printf("sys time:%f sec\n",(t_buf_end.tms_stime-t_buf_start.tms_stime)/(double)tck);

}
